import request from "@/axios"
export default ({
  namespaced:true,
  state: {
    //好友申请记录
    FriendRecord:null,
    //未处理条数
    FriendRecordCount:0,

    ///朋友
    Friends:[],


    //点赞 收藏
    LikeCollect:5,
  },
  getters: {},
  mutations: {
    SETDATA:(state,data)=>{
        state.FriendRecord = data.FriendRecord
        state.FriendRecordCount=data.FriendRecordCount
        state.Friends=data.Friends
    },
    //设置好友申请记录
    SETFRIENDRECORD:(state,data)=>{
      state.FriendRecord = data.FriendRecord
      state.FriendRecordCount=data.FriendRecordCount
    },
    //设置好朋友
    SETFRIENDS:(state,data) =>{
      state.Friends=data.Friends
    }
  },
  actions:{
    //初始化 好友申请记录 点赞收藏记录 等等
    async initInform(context,uid){
         let res = await request.get("/api/inform/getAll",{params:{uid}})
         if(res.data.code ==200){
            context.commit('SETDATA',res.data.data)
         }else  console.log('===初始化信息获取失败===')
    },
    //
    async refreshFriendRecord(context,uid){
        let res = await request.get("/api/inform/getFriendRecord",{params:{uid}})
        if(res.data.code ==200){
          context.commit('SETFRIENDRECORD',res.data.data)
        }else  console.log('===好友申请记录获取失败===')
    },

    async refreshFriends(context,uid){
    
      let res = await request.get("/api/inform/getFriends",{params:{uid}})
      if(res.data.code ==200){
        context.commit('SETFRIENDS',res.data.data)
      }else  console.log('===好友获取失败===')
    }
  },
})